---
description: "Reference for Nitric's v0 JVM library - Creates a reference to a secret in the secrets manager."
---

# JVM - secret()

Creates a reference to a secret in the secrets manager.

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("apiKey").with(SecretPermission.Access);

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("apiKey").with(SecretPermission.Access)

  Nitric.run()
}
```

</TabItem>

</Tabs>

## Parameters

<Properties>
  <Property name="name" required type="String">
    The unique name of this secret within the secrets manager.
  </Property>
</Properties>

## Access

All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details about infrastructure [security](/get-started/foundations/infrastructure/security).

### Available permissions:

---

**SecretPermission.Put**

This permission allows your code to set a new latest value for a secret.

---

**SecretPermission.Access**

This permission allows your code to retrieve secret values.

---

## Examples

### Create a reference to a secret

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("apiKey").with(SecretPermission.Put);

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("apiKey").with(SecretPermission.Put)

  Nitric.run()
}
```

</TabItem>

</Tabs>

### See also

- [secret().put()](./secret-put)
- [secret().version()](./secret-version)
- [secret().latest()](./secret-latest)
- [secret().version().access()](./secret-version-access)
